﻿<Window x:Class="ResourceBlender_Express.WinAddApplication"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:validators="clr-namespace:ResourceBlender_Express.Validators"
    xmlns:converters="clr-namespace:ResourceBlender_Express.Converters"
    loc:WindowService.EscapeClosesWindow="True"
    Title="Add Application" Height="460" Width="400"
    DataContextChanged="Window_DataContextChanged"
    Initialized="Window_Initialized"
    WindowStartupLocation="CenterOwner" SizeToContent="Height"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlender-Express;component/Resources/images/resourceblender.ico">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Save" Executed="Save" />
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <CommandBinding Command="ApplicationCommands.New" Executed="AddBundle" />
        <CommandBinding Command="loc:ResourceBlenderCommands.Edit" Executed="EditBundle" CanExecute="CanExecuteEditBundle" />
        <CommandBinding Command="loc:ResourceBlenderCommands.Delete" Executed="DeleteBundle" CanExecute="CanExecuteDeleteBundle" />
    </Window.CommandBindings>
    <StackPanel Margin="6">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Grid.Column="0">Application Name</Label>
            <TextBox Grid.Row="0" Grid.Column="1" x:Name="txtApplicationName">
                <Binding Path="ApplicationName" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <validators:StringValidationRule
                            MinimumLength="0"
                            MaximumLength="255"
                            ErrorMessage="Application name must be entered" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox>

            <Label Grid.Row="1" Grid.Column="0">Display Name</Label>
            <TextBox Grid.Row="1" Grid.Column="1" x:Name="txtDisplayName">
                <Binding Path="DisplayName" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <validators:StringValidationRule
                            MinimumLength="0"
                            MaximumLength="255"
                            ErrorMessage="Display name must be entered" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox>
        </Grid>
        <TabControl x:Name="tbcLanguagesBundles" MinHeight="300">
            <TabItem Header="Languages">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="200" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    
                    <Label Grid.Row="0" Grid.Column="0">Selected Languages</Label>
                    <ListBox Grid.Row="1" Grid.Column="0" x:Name="lstSelectedLanguages" DisplayMemberPath="Value" SelectedValuePath="Key" SelectionMode="Extended" />
                    <StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
                        <Button Name="btnAddLanguage" Margin="2" Click="btnAddLanguage_Click" IsEnabled="{Binding ElementName=lstAvailableLanguages,Path=HasItems}">&lt;&lt;</Button>
                        <Button Name="btnRemoveLanguage" Margin="2" Click="btnRemoveLanguage_Click" IsEnabled="{Binding ElementName=lstSelectedLanguages,Path=HasItems}">&gt;&gt;</Button>
                    </StackPanel>
                    <Label Grid.Row="0" Grid.Column="2">Available Languages</Label>
                    <ListBox Grid.Row="1" Grid.Column="2" x:Name="lstAvailableLanguages" DisplayMemberPath="Value" SelectedValuePath="Key" SelectionMode="Extended">
                    </ListBox>
                    <loc:ImageButton Grid.Row="2" Grid.Column="0" Margin="0,2,8,2" Click="btnCustomLanguage_Click" Text="Add Custom Language" Image="Resources/images/add_16.png" ToolTip="Add Custom Language" AlwaysShowBorder="True" ImageLocation="Left" />
                    
                    <Label Grid.Row="3" Grid.Column="0">Default Language</Label>
                    <ComboBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2" x:Name="cboDefaultLanguage" Margin="2,2,0,2" SelectedValue="{Binding Path=DefaultLanguage,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="Key" DisplayMemberPath="Value"></ComboBox>
                </Grid>
            </TabItem>
            <TabItem Header="Bundles">
                <StackPanel>
                    <ToolBar>
                        <loc:ImageButton x:Name="btnAdd" Command="ApplicationCommands.New" Text="Add" Image="Resources/images/add_16.png" ShowText="False" ToolTip="Add Bundle" Style="{StaticResource ToolBarButton}" />
                        <loc:ImageButton x:Name="btnEdit" Command="loc:ResourceBlenderCommands.Edit" Text="Edit" Image="Resources/images/edit_16.png" ShowText="False" ToolTip="Edit Bundle" Style="{StaticResource ToolBarButton}" />
                        <loc:ImageButton x:Name="btnDelete" Command="loc:ResourceBlenderCommands.Delete" Text="Delete" Image="Resources/images/delete_16.png" ShowText="False" ToolTip="Delete Bundle" Style="{StaticResource ToolBarButton}" />
                    </ToolBar>
                    <ListBox x:Name="lstBundles" Height="150" ItemTemplate="{StaticResource BundleTemplate}" SelectionMode="Extended">
                    </ListBox>
                </StackPanel>
            </TabItem>
        </TabControl>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
            <Button x:Name="btnSave" MinWidth="70" IsDefault="True" Command="ApplicationCommands.Save">Save</Button>
            <Button x:Name="btnCancel" MinWidth="70" IsCancel="True" Command="ApplicationCommands.Close" Margin="2,2,0,2">Cancel</Button>
        </StackPanel>
    </StackPanel>
</Window>
